<?php
	include 'slog.function.php';

	 function add_income($username,$money,$money_type,$datatype,$des_user=""){
	$uinfo=getuserinfo($username);
	if(empty($uinfo)){dumplog('添加收入 用户信息为空！');}
	$record3 ["UG_type"] = $money_type;
	switch ($money_type){
		case 'jb':
			$record3 ["UG_allGet"] = $uinfo['ue_money'];
			$uinfo['ue_money']+=$money;
//                M('user')->save($uinfo);
			M('user')->where(array('UE_ID'=>$uinfo['ue_id']))->save(array('UE_money'=>$uinfo['ue_money']));
			$record3 ["UG_balance"] = $uinfo['ue_money'];
			break;
		case 'tj':
			$record3 ["UG_allGet"] = $uinfo['tj_he'];
			$uinfo['tj_he']=intval( $uinfo['tj_he'])+ $money;
			M('user')->where(array('UE_ID'=>$uinfo['ue_id']))->save(array('tj_he'=>$uinfo['tj_he']));
			$record3 ["UG_balance"] = $uinfo['tj_he'];
			dumplog('获得推荐奖:'.$money,2);
			break;
		case 'jhb':
			$record3 ["UG_allGet"] = $uinfo['user_jhb'];
			$uinfo['user_jhb']+=$money;
			M('user')->where(array('UE_ID'=>$uinfo['ue_id']))->save(array('user_jhb'=>$uinfo['user_jhb']));
			$record3 ["UG_balance"] = $uinfo['user_jhb'];
			break;
	}

	$record3 ["UG_dataType"] =$datatype;
	switch ($datatype){
		case 'xtzs':
			$record3 ["UG_note"] = '系统操作';
			break;
		case 'jsbz':
			$record3 ["UG_note"] = '接受帮助扣款';
			break;
		case 'tj':
			$record3 ["UG_note"] = '推荐奖励';
			break;
		case 'ax':
			$record3 ["UG_note"] = '爱心奖励';
			break;
		case 'tgbz':
			$record3 ["UG_note"] = '提供帮助扣除';
			break;
		case 'zz':
			$des_uinfo=getuserinfo($des_user);
			$record3 ["touser"]=$des_user;
			$record3 ["UG_note"] = '转账给'. $des_uinfo['user_bankuser'] . "(" . $des_user . ")";
			break;
		case 'fzz':
			$des_uinfo=getuserinfo($des_user);
			$record3 ["fromuser"]=$des_user;
			$record3 ["UG_note"] = '来自'. $des_uinfo['user_bankuser'] . "(" . $des_user . ")的转账";
			break;

	}

	$record3 ["UG_account"] = $username; // 登入转出账户
	$record3 ["UG_money"] = $money;
	$record3["UG_getTime"]= date ( 'Y-m-d H:i:s', time () ); //操作时间
	$reg4 = M ( 'userget' )->add ( $record3 );
	
}
?>